<?php

/**
* Update logs
* Oct 14, 2010      immanuel192        Fix bug loop back forever in flow set & get
* Jan 27, 2011      immanuel192        Change this action to work with New Sub theme of prayonline 
*/
if (!defined('EXPONENT')) exit('');
ob_start();

if (isset($_GET['redirecturl'])) {
	$redirect = urldecode($_GET['redirecturl']);
	if (substr($redirect,0,4) != 'http') {
		$redirect = URL_FULL.$redirect;
	}
	exponent_sessions_set('redirecturl',$redirect);
} else {
	$url=exponent_flow_get();
	if (strstr($url, "loginredirect"))
	{
		$url="/"; // fix bug loopback forever
	}
	exponent_sessions_set('redirecturl',$url);
}

//$SYS_FLOW_REDIRECTIONPATH = 'loginredirect'; 
//exponent_flow_set(SYS_FLOW_PUBLIC,SYS_FLOW_ACTION);

if (exponent_sessions_loggedIn()) {
	header('Location: ' . exponent_sessions_get('redirecturl'));
	exit('Redirecting...');
} 

$i18n = exponent_lang_loadFile('modules/loginmodule/actions/loginredirect.php');
loginmodule::show('Default',null,$i18n['login']);


$template = new template('loginmodule','_login_redirect');

$template->assign('output',ob_get_contents());
ob_end_clean();
$template->output();

//no head for mobile
global $browser;
if(!$browser->isMobile())
{
exponent_sessions_set("AB_THEME_TOP_CONTAINER_SRC",LANG."_login_info_src_head");
exponent_sessions_set("AB_THEME_TOP_CONTAINER_TYPE","textmodule");
}
else
{
 exponent_sessions_set("AB_THEME_TOP_CONTAINER_SRC",LANG."_login_mobile");   
}

?>
